#include "../inc/sched.h"

#include <linux/cpu.h>

static bool dequeue_task_idle(struct rq *rq, struct task_struct *p, int flags)
{
    return true;
}

static struct task_struct *pick_task_idle(struct rq *rq)
{

    return rq->idle;
}

static void put_prev_task_idle(struct rq *rq, struct task_struct *prev, struct task_struct *next)
{
}

static void set_next_task_idle(struct rq *rq, struct task_struct *next, bool first)
{
}

static void task_tick_idle(struct rq *rq, struct task_struct *curr, int queued)
{
}

static void init_idle_rq(struct rq *rq)
{
}

/*
 * Idle tasks are unconditionally rescheduled:
 */
static void wakeup_preempt_idle(struct rq *rq, struct task_struct *p, int flags)
{
	resched_curr(rq);
}

DEFINE_SCHED_CLASS(idle) = {
    /* no enqueue/yield_task for idle tasks */

    /* dequeue is not valid, we print a debug message there: */
    .dequeue_task = dequeue_task_idle,
    .pick_task = pick_task_idle,
    .put_prev_task = put_prev_task_idle,
    .set_next_task = set_next_task_idle,

    .task_tick = task_tick_idle,
    .wakeup_preempt = wakeup_preempt_idle,

    .init_rq = init_idle_rq,
};
